
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Netty - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Netty - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Netty是什么？它与传统的Java Web服务器（如Tomcat）有何不同？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Netty是由JBOSS提供的一个java开源框架，它本身是对JDK 1.4以后提供的NIO的封装。与Tomcat这类服务器不同，Netty不需要运行在其中，而是可以单独构建一个服务器，例如HTTP服务器、socket服务器或websocket服务器。</div>
          </div>
          <div class="card-source">来源: 1 Netty是什么</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">Netty的主从多线程模型是如何工作的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在主从多线程模型中，服务端包含两个线程池。一个主线程池（master）主要负责处理客户端的连接请求，而另一个从线程池（slave）则主要负责处理已连接客户端的数据读写操作。</div>
          </div>
          <div class="card-source">来源: 3. Netty线程模型</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">组件</div>
          <div class="card-question">在Netty中，Bootstrap和ServerBootstrap组件的主要职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">组件</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Bootstrap和ServerBootstrap是Netty的引导组件，它是一个Netty程序的起点，作用是简化NIO的开发步骤，负责配置和串联各个组件，如设置线程组、通道类型和处理器等。</div>
          </div>
          <div class="card-source">来源: 2.1 Netty中的重要组件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">ChannelPipeline在Netty中扮演什么角色？它如何组织ChannelHandler？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ChannelPipeline的主要作用是管理各种ChannelHandler（业务控制器）。它提供一个链式管理模式，将多个ChannelHandler链接在一起，让入站和出站事件在其中传播和处理。</div>
          </div>
          <div class="card-source">来源: 4 ChannelPipeline</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">组件</div>
          <div class="card-question">请解释Netty中EventLoopGroup、EventLoop和Channel之间的关系。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">组件</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">EventLoopGroup是EventLoop的组合，可以包含多个EventLoop。而EventLoop则负责循环服务于Channel，一个EventLoop可以服务于多个Channel。Channel代表一个Socket连接，是通讯的载体。</div>
          </div>
          <div class="card-source">来源: 2.1 Netty中的重要组件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">WebSocket协议解决了HTTP协议的什么核心问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">WebSocket解决了HTTP协议只能由客户端发起请求，服务端无法主动推送消息的问题。通过WebSocket，客户端和服务端都可以主动推送消息，从而实现全双工通信，并且它没有同源策略的限制。</div>
          </div>
          <div class="card-source">来源: 7.1  什么是WebSocket</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Netty中实现WebSocket心跳检测时，通常使用哪两种状态帧？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">WebSocket心跳检测通常使用PingWebSocketFrame（ping帧，由客户端发送）和PongWebSocketFrame（pong帧，由服务端响应）这两种状态帧来完成。</div>
          </div>
          <div class="card-source">来源: 7.2.2 状态帧 -- 检测心跳</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Netty中处理网络数据时，为什么需要Encoder和Decoder？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为网络传输的数据都是字节（byte）流。当Netty接收到数据时，需要使用Decoder（解码器）将字节解码成Java对象。当需要向外发送数据时，则需要使用Encoder（编码器）将Java对象编码成字节流进行传输。</div>
          </div>
          <div class="card-source">来源: 2.1 Netty中的重要组件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Netty中构建一个HTTP服务器时，通常需要添加哪些核心的编解码器？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在构建HTTP服务器时，通常需要在ChannelPipeline中添加HttpServerCodec（HTTP编解码器）和HttpObjectAggregator。HttpServerCodec用于HTTP的编解码，而HttpObjectAggregator则会将HTTP消息的多个部分聚合成一个完整的FullHttpRequest对象。</div>
          </div>
          <div class="card-source">来源: 5.1 HttpServer</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
